<html>
<head><meta charset="utf-8"><title>formality of adding new errors · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/formality.20of.20adding.20new.20errors.html">formality of adding new errors</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227337233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/formality%20of%20adding%20new%20errors/near/227337233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/formality.20of.20adding.20new.20errors.html#227337233">(Feb 22 2021 at 21:06)</a>:</h4>
<p>in <a href="https://github.com/rust-lang/rust/blob/master/compiler/rustc_attr/src/builtin.rs#L795-L800">https://github.com/rust-lang/rust/blob/master/compiler/rustc_attr/src/builtin.rs#L795-L800</a> , I see that the first error state has actually registered a distinct new type of error, whereas the second error state appears to be more ad-hoc and just uses <code>struct_span_error</code>. Which approach is preferred, considering that the error I want to add is internal to the compiler itself?</p>



<a name="227337788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/formality%20of%20adding%20new%20errors/near/227337788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/formality.20of.20adding.20new.20errors.html#227337788">(Feb 22 2021 at 21:10)</a>:</h4>
<p>Is this an internal lint? I would use <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.struct_lint_node">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.struct_lint_node</a> where possible, since you don't have an error code but presumably you want to let people <code>allow</code> or <code>deny</code> it.</p>



<a name="227338858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/formality%20of%20adding%20new%20errors/near/227338858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/formality.20of.20adding.20new.20errors.html#227338858">(Feb 22 2021 at 21:17)</a>:</h4>
<p>not for a brand-new lint, I want to add an error when somebody writes a <code>#[rustc_deprecated]</code> attribute with an invalid value for the <code>since</code> field. Currently rustc requires the field's presence (the first line in my prior link) but elsewhere it silently ignores if the field isn't a valid version string. I would like to use an error to enforce that the string is a valid value.</p>



<a name="227340647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/formality%20of%20adding%20new%20errors/near/227340647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/formality.20of.20adding.20new.20errors.html#227340647">(Feb 22 2021 at 21:31)</a>:</h4>
<p>actually, I think I'll just expand that MissingSince error there to encompass both a missing and an invalid "since" field</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>